#include "../../include/shape/Arrows.h"

void ArrowsClass::draw()
{
	int x1 = coord.x - arrLength, y1 = coord.y;
	int x2 = coord.x - arrLength / 5, y2 = coord.y + 1;
	int x3 = coord.x - arrLength / 5, y3 = coord.y - 1;
	if (m_ifFill) {
		if (getfillcolor() != m_fillColor) setfillcolor(m_fillColor);
		POINT pts[] = { {coord.x, coord.y}, {x2, y2}, {x3, y3} };
		line(x1, y1, coord.x, coord.y);
		fillpolygon(pts, 3);
		
	}
	else {
		if (getlinecolor() != m_color) setlinecolor(m_color);
		line(x1, y1, coord.x, coord.y);
		line(x2, y2, coord.x, coord.y);
		line(x3, y3, coord.x, coord.y);
	}
}

void ArrowsClass::move(Dir dir, int distance)
{
	LPRECT lpRect = new tagRECT();
	GetWindowRect(GetHWnd(), lpRect);
	int length = lpRect->right - lpRect->left;
	int height = abs(lpRect->bottom - lpRect->top);
	switch (dir)
	{
	case Dir::Left:
		coord.x -= distance;
		if (coord.x <= arrLength) coord.x = arrLength;
		break;
	case Dir::Top:
		coord.y -= distance;
		if (coord.y <= arrLength / 5) coord.y = arrLength / 5;
		break;
	case Dir::Right:
		coord.x += distance;
		if (coord.x >= length) coord.x = length;
		break;
	case Dir::Bottom:
		coord.y += distance;
		if (coord.y >= height - arrLength / 5) coord.y = height - arrLength / 5;
		break;
	default:
		break;
	}
}
